import Position

class Move(object):
	def __init__(self):
		self.moveTo = []
	def setFrom(self,fromm):
		self.moveFrom = fromm
	def getFrom(self):
		return self.moveFrom
	def getTo(self):
		return self.moveTo
	def addTo(self,to):
		return self.moveTo.append(to)
	def toString(self):
		string = "from:" +self.moveFrom.toString()+" "
		for pos in self.moveTo:
			string+= "to:"+pos.toString()+" "
		return string

def createMove(fromm,to):
	move = Move()
	move.setFrom(fromm)
	for singleTo in to:
		move.addTo(singleTo)
	return move	

def findLongest(moves):
	size = 1
	longMoves = []
	for move in moves:
		length = len(move.getTo())
		if length>size:
			size = length
			longMoves = []
		if length==size:
			longMoves.append(move)
	return longMoves
	
def getCopyOfMove(move):
	copyMove = Move()
	copyMove.setFrom(Position.getCopyOfPosition(move.getFrom()))
	for singleTo in move.getTo():
		copyMove.addTo(Position.getCopyOfPosition(singleTo))
	return copyMove
		
def getCopyOfMoves(moves):
	copyMoves = []
	for move in moves:
		copyMoves.append(getCopyOfMove(move))
	return copyMoves